package cn.tedu.oa_system.controller;

import cn.tedu.oa_system.base.json_result.ResultDataDto;
import cn.tedu.oa_system.base.json_result.ResultDto;
import cn.tedu.oa_system.pojo.TypeList;
import cn.tedu.oa_system.pojo.in.FindLikeKeyIn;
import cn.tedu.oa_system.pojo.in.TypeListIn;
import cn.tedu.oa_system.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author MW
 * @Description 类型控制器
 * @CreateDate 2023/3/7
 */
@RestController
@RequestMapping("/type")
public class TypeController {

    @Autowired
    private TypeService typeService;

    @PostMapping("/addtype")
    private ResultDto<Void> addType(@RequestBody TypeListIn typeListIn){
        return typeService.save(typeListIn);
    }

    @PostMapping("/delete")
    private ResultDto<Void> deleteType(@RequestBody TypeListIn typeListIn){
        return typeService.deleteById(typeListIn);
    }

    @PostMapping("/update")
    private ResultDto<Void> updateType(@RequestBody TypeListIn typeListIn){
        return typeService.update(typeListIn);
    }

    @PostMapping("/list")
    private ResultDataDto<TypeList> list(@RequestBody FindLikeKeyIn likeKeyIn){
        return typeService.list(likeKeyIn);
    }
}
